package com.lgl.controller;

import com.lgl.dto.AddUserDto;
import com.lgl.dto.GetUserDto;
import com.lgl.dto.UpdateUserDto;
import com.lgl.dto.UserDto;
import com.lgl.entity.ResponseResult;
import com.lgl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public ResponseResult getUserList(Integer pageSize,Integer pageNum, GetUserDto getUserDto){
       return userService.getUserList(pageNum,pageSize,getUserDto);
    }
    @PostMapping
    public ResponseResult addUser(@RequestBody AddUserDto addUserDto){
       return userService.addUser(addUserDto);
    }
    @DeleteMapping("/{id}")
    public ResponseResult deleteUser(@PathVariable Long id){
        return userService.deleteUser(id);
    }
    @GetMapping("/{id}")
    public ResponseResult getUser(@PathVariable Long id){
        return userService.getUser(id);
    }
    @PutMapping
    public ResponseResult updateUser(@RequestBody UpdateUserDto updateUserDto){
        return userService.updateUser(updateUserDto);
    }
    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody UserDto userDto){
        return userService.changeStatus(userDto);
    }
}
